﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CallAjax.aspx.cs" Inherits="ENT.PM.Ws.CallAjax" %>
<%@ Import Namespace="System.Web.Services" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>ASP.NET AJAX Web Services: Web Service Sample Page</title>

 <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">   
</script>  

   
  <script type="text/javascript">

      $(document).ready(function () {

          $("#sayHelloButton").click(function (event) {
              $.ajax({
                  type: "POST",
                  url: "./Service.asmx/GetLogin",
                  data: "{'sUsername': '" + $('#name').val() + "','sPassword': '" + $('#clave').val() + "'}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function (msg) {
                      AjaxSucceeded(msg);
                  },
                  error: AjaxFailed

              });
          });

      });
      function AjaxSucceeded(result) {
          alert("Resultado="+result.d);
          /*for (var c in result.d) {
              alert(result.d[c].Status);
          }*/
      }

      function AjaxFailed(result) {
          alert(result.status + ' ' + result.statusText);
      }


     

  </script>  
</head>
<body>
    <form id="form1" runat="server">
     <h1> ASP.NET AJAX Web Services/jQuery </h1>
        Name/clave: 
        <input id="name" />
        <input id="clave" /><br />
        <input id="sayHelloButton" value="Login"
               type="button"   />

    </form>
</body>
</html>